package com.xdcplus.web.handler;

import com.xdcplus.etl.schedule.annotation.Job;
import com.xdcplus.web.common.pojo.entity.DwWorkConf;
import com.xdcplus.web.mapper.DwWorkConfMapper;
import com.xdcplus.web.service.DwWorkConfService;
import com.xdcplus.web.service.TpCrackService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.time.LocalDateTime;

/**
 * bsg,psg检测数据同步到doris
 */
@Slf4j
@Component
public class TpCrackSyncHandler extends AbstractJobHandler {

    private final String HANDLER_NAME = "TpCrackSyncHandler";

    @Resource
    private TpCrackService tpCrackService;
    @Resource
    private DwWorkConfService dwWorkConfService;

    @Job(HANDLER_NAME)
    @Override
    public void handler(String param) {
        DwWorkConf dwWorkConf = dwWorkConfService.queryDwWorkConfByEtlName(HANDLER_NAME);
        if (dwWorkConf.getEtlEndTimestamp().toLocalDateTime()
                        .isBefore(LocalDateTime.now())) {
            log.info("同步开始...{}",dwWorkConf);
            tpCrackService.syncData(dwWorkConf);
            endJob(dwWorkConf);
        }
    }

    @Override
    public Object execute(DwWorkConf conf) {
        return null;
    }

}

